import 'package:flutter/material.dart';
import 'package:voice_tx/model/nav_button.dart';

class Index extends StatelessWidget {
  final List<NavButton> buttons;

  final bool isSingle;

  final String title;

  Index(this.title, this.buttons)
      : isSingle = buttons == null || buttons.length == 0;

  @override
  Widget build(BuildContext context) {
    return new DefaultTabController(
        length: buttons.length,
        child: new Scaffold(
          appBar: new AppBar(
            title: const Text('首页'),
            bottom: new TabBar(
              isScrollable: true,
              tabs: buttons.map((NavButton button) {
                return new Tab(
                  text: button.title, icon: new Icon(button.iconData));
              }).toList(),
            ),
          ),
          body: new TabBarView(children: buttons.map((button) {
            return new Padding(
                padding: const EdgeInsets.all(16.0),
                child: new Text(button.title));
          }).toList()),
        ));
  }
}
